#ifndef THREAD_H
#define THREAD_H

#include <QtGui/QMainWindow>
#include "ui_thread.h"
#include <QtGui>
#include <QThread>
#include <QTcpSocket>
#include <QStringList>
#include <QTcpServer>

class temp : public QObject
{
	Q_OBJECT;
public:
	temp(QPlainTextEdit *,QTcpSocket *);
private slots:
	void Doit();
private:
	QPlainTextEdit *text;
	QTcpSocket *client;
};


class thread : public QMainWindow
{
	Q_OBJECT

public:
	thread(QWidget *parent = 0, Qt::WFlags flags = 0);
	~thread();
	
private slots:
		void NewCon();
private:
	//Ui::threadClass ui;
	//QLabel * lab;
	QTcpServer * server;
	QPlainTextEdit *text;
};


class FortuneServer : public QTcpServer
{
	Q_OBJECT

public:
	FortuneServer(QObject *parent = 0);

protected:
	void incomingConnection(int socketDescriptor);

private:
	QStringList fortunes;
};


//! [0]
class FortuneThread : public QThread
{
	Q_OBJECT

public:
	FortuneThread(int socketDescriptor, const QString &fortune, QObject *parent);

	void run();

signals:
	void error(QTcpSocket::SocketError socketError);

private:
	int socketDescriptor;
	QString text;
};


#endif // THREAD_H
